package com.baoxin.chenxixc4coach.dialog;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.DialogFragment;
import android.view.View;

import com.baoxin.chenxixc4coach.LoginActivity;
import com.baoxin.chenxixc4coach.java.IActivityLifeCheck;

public class BaseDialogFragment extends DialogFragment implements IActivityLifeCheck {
    protected Activity activity;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.activity = (Activity) context;
    }

    @Override
    public void onStart() {
        super.onStart();
        final int uiOpions = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        final View decorView = getDialog().getWindow().getDecorView();
        decorView.setSystemUiVisibility(uiOpions);
        decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int visibility) {
                decorView.setSystemUiVisibility(uiOpions);
            }
        });
    }

    @Override
    public void onDetach() {
        super.onDetach();
        activity = null;
    }

    public boolean activityAlive() {
        return activity == null ? false : true;
    }

}
